package com.tjs.lucky.domain.activity.service.stateflow.event;

import com.tjs.lucky.common.ActivityState;
import com.tjs.lucky.common.ResponseCode;
import com.tjs.lucky.common.Result;
import com.tjs.lucky.domain.activity.service.stateflow.AbstractState;
import org.springframework.stereotype.Component;

/**
 * @Author: 田佳澍
 * @Description: 活动开启状态
 * @DateTime: 2023/5/22 15:20
 **/
@Component
public class OpenState extends AbstractState {

    @Override
    public Result arraignment(Long activityId, Enum<ActivityState> currentState) {
        return Result.buildResult(ResponseCode.UN_ERROR, "活动开启不可提审");
    }

    @Override
    public Result checkPass(Long activityId, Enum<ActivityState> currentState) {
        return Result.buildResult(ResponseCode.UN_ERROR, "活动开启不可审核通过");
    }

    @Override
    public Result checkRefuse(Long activityId, Enum<ActivityState> currentState) {
        return Result.buildResult(ResponseCode.UN_ERROR, "活动开启不可审核拒绝");
    }

    @Override
    public Result checkRevoke(Long activityId, Enum<ActivityState> currentState) {
        return Result.buildResult(ResponseCode.UN_ERROR, "活动开启不可撤销审核");
    }

    @Override
    /**
     * 【活动开启】状态向【活动关闭】状态流转
     */
    public Result close(Long activityId, Enum<ActivityState> currentState) {
        boolean isSuccess = activityRepository.alterStatus(activityId, currentState, ActivityState.CLOSE);
        return isSuccess ? Result.buildResult(ResponseCode.SUCCESS, "活动关闭完成") : Result.buildErrorResult("活动状态变更失败");
    }

    @Override
    public Result open(Long activityId, Enum<ActivityState> currentState) {
        return Result.buildResult(ResponseCode.UN_ERROR, "活动不可重复开启");
    }

    @Override
    /**
     * 【活动开启】状态向活动【进行中状态】进行流转
     */
    public Result doing(Long activityId, Enum<ActivityState> currentState) {
        boolean isSuccess = activityRepository.alterStatus(activityId, currentState, ActivityState.DOING);
        return isSuccess ? Result.buildResult(ResponseCode.SUCCESS, "活动变更活动中完成") : Result.buildErrorResult("活动状态变更失败");
    }

}

